package com.tth.learn.addproperties.java;

import java.io.Serializable;

/**
 * Person类需要满足如下要求，才可序列化
 *  1.需要实现Serializable接口
 *  2.当前类需要提供一个全局常量serialVersionUID(为了识别是哪个类)
 *
 * @Author tth
 * @Date 2022/12/27 9:43
 */
public class Person implements Serializable {

    private static final long serialVersionUID = -2217769636819659120L;

    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
